<?php

namespace Backend\Widgets;

use DuAdmin\Helpers\CrontabHelper;
use yii\base\Widget;
use yii\helpers\Url;

/**
 *
 * @author dungang
 */
class StartCron extends Widget
{
    public function run()
    {
        list($cronStatus, $cronTracedAt, $isRunning) = CrontabHelper::prepareCronSetting();
        if ($isRunning) {
            $url = Url::to(['/cron/run']);
            $this->view->registerJs("$.get('${url}')");
        }
    }
}
